package com.hankol.feature_wine_meal.viewmodel

import android.app.Activity
import android.content.Context
import androidx.core.content.ContextCompat
import androidx.lifecycle.MutableLiveData
import com.baselibrary.base.mvvm.BaseViewModel
import com.baselibrary.utils.ScreenUtils
import com.flyco.tablayout.SlidingTabLayout
import com.hankol.feature_wine_meal.R
import com.hankol.feature_wine_meal.bean.AppetizerDiet
import com.hankol.feature_wine_meal.bean.CuisineRefreshBean
import com.hankol.feature_wine_meal.respository.WineMealRequestManager

/**
 * @author: 关忆北、
 * @date: 2022/6/17
 * @Des：
 */
class CuisineViewModel : BaseViewModel() {
    val refreshCuisineLiveData: MutableLiveData<ArrayList<CuisineRefreshBean>> = MutableLiveData()
    val changeBatchCuisineLiveData: MutableLiveData<ArrayList<AppetizerDiet>> = MutableLiveData()//换一批

    fun upTabLayout(context: Context, pos: Int, tab: SlidingTabLayout) {
        val tabCount = tab.tabCount
        for (index in 0 until tabCount) {
            val mTabTv = tab.getTitleView(index)
            mTabTv.paint.isFakeBoldText = true
            if (pos == index) {
                mTabTv.textSize = 18f
                mTabTv.setTextColor(ContextCompat.getColor(context, R.color.color_333333))
            } else {
                mTabTv.textSize = 14f
                mTabTv.setTextColor(ContextCompat.getColor(context, R.color.color_999999))
            }
        }
    }


    fun changeHeight(activity: Activity): Int {
        return ScreenUtils.marginSum(activity, 20, 20, 200, 200, 10)
    }


    fun reqCuisine() {
        WineMealRequestManager.getInstance().reqCuisine(refreshCuisineLiveData)
    }

    fun reqChangeBatch(categoryId: Long) {
        WineMealRequestManager.getInstance().reqChangeBatch(categoryId, changeBatchCuisineLiveData)
    }


}